package com.jufa_3.controller;

import com.jufa_3.common.R;
import com.jufa_3.dto.ComboVO;
import com.jufa_3.entity.Combo;
import com.jufa_3.mapper.ComboMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/combo")
public class ComboController {

    @Autowired
    private ComboMapper comboMapper;

    @GetMapping("/getCostItems")
    public R<List<ComboVO>> getCostItems(Combo combo) {
        return R.success(comboMapper.selectCombos(combo));
    }

    @GetMapping("/updataCombo")
    public R<Integer> updateCombo(Combo combo) {
        combo.setUpdataTime(LocalDateTime.now());
        return R.success(comboMapper.updateCombo(combo));
    }

    @GetMapping("/getAllComboInfo")
    public R<List<ComboVO>> getAllComboInfo(){
        List<ComboVO> comboVOS = comboMapper.selectCombos(new Combo("综合套餐","1"));
        return R.success(comboVOS);
    }

}
